using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Input;

public class InputHandler
{
    private InputMessageFilter _imf = null;

    private string _inputBuffer = String.Empty;

    public string InputBuffer
    {
        get { return _inputBuffer; }
        set { _inputBuffer = value; }
    }

    public InputHandler()
    {
        _imf = new InputMessageFilter();
        _imf.Enabled = true;
        _imf.TranslateMessage = true;
    }

    public bool KeyPressed(Keys key)
    {
        for(int keyIndex=0;keyIndex<_imf.KeyData.Count;keyIndex++)
            if(_imf.KeyData[keyIndex].Key==key)
                return true;

        return false;
    }

    public string FlushBuffer()
    {
        _inputBuffer = _imf.GetText();
        _imf.KeyData = new Stack<KeyData>();
        return _inputBuffer;
    }
}
